package risk.control.application.utils;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

/**
 * CreationTime:2018/8/31
 * Describe:设置全屏/取消全屏工具类
 * Author:hm
 **/

public class TitleBarUtils {
    /**
     * @param activity activity
     *                 <a href="https://blog.csdn.net/cention168/article/details/124037221">...</a>
     */
    public static void setFullScreen_v2(Activity activity) {
        Window window = activity.getWindow();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            WindowManager.LayoutParams lp = window.getAttributes();
            //用在android高版本满屏，穿过摄像头。
            lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
            window.setAttributes(lp);
        } else {
            window.requestFeature(Window.FEATURE_NO_TITLE);
            window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
        final View decorView = window.getDecorView();
        //View.SYSTEM_UI_FLAG_HIDE_NAVIGATION用来隐藏底部悬浮条
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

    }
}
